﻿<%@ Page Title="Cập nhật khối lượng" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="KhoiLuongEdit.aspx.cs" Inherits="QuanLyHopDong.Web.HopDong.KhoiLuongEdit" %>

<%@ Import Namespace="Resources" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%=GlobalStrings.Edit %> Khối lượng</h2>
    <p></p>
    <span class="failureNotification">
        <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></span>

    <div>
        <table>
            <tr>
                <td>
                    <b>Số HĐ:</b>
                    <a href="Edit.aspx?id=<%=Request.Params["hopDongId"] %>">
                        <asp:Literal ID="ltrSoHopDong" runat="server"></asp:Literal></a>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Tên HĐ:</b>
                    <asp:Literal ID="ltrTenHopDong" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Đơn vị ký HĐ:</b>
                    <asp:Literal ID="ltrTenDonVi" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Loại dự án:</b>
                    <asp:Literal ID="ltrLoaiDuAn" runat="server"></asp:Literal>
                </td>
            </tr>
        </table>
    </div>

    <p></p>

    <table>
        <tr>
            <td style="vertical-align: top;">
                <div style="margin-right: 50px; vertical-align: top;">
                    <p>
                        <label>Mã tuyến:</label>
                        <asp:TextBox ID="txtMaTuyen" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                    </p>
                    <p>
                        <label>Điểm đầu:</label>
                        <asp:TextBox ID="txtDiemDau" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                    </p>
                    <p>
                        <label>Điểm cuối:</label>
                        <asp:TextBox ID="txtDiemCuoi" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                    </p>
                    <p>
                        <label>Chiều dài tuyến (m):</label>
                        <asp:TextBox ID="txtChieuDaiTuyen" runat="server"></asp:TextBox>
                    </p>
                    <p>
                        <label>Loại cáp:</label>
                        <asp:TextBox ID="txtLoaiCap" runat="server"></asp:TextBox>
                    </p>
                </div>
            </td>
            <td style="vertical-align: top;">
                <div style="vertical-align: top;">
                    <p>
                        <label>Đội thi công</label>
                        <asp:DropDownList ID="ddlDoiThiCong" runat="server"></asp:DropDownList>
                    </p>
                    <p>
                        <label>Tiến độ thi công:</label>
                        <asp:DropDownList ID="ddlTienDo" runat="server">
                            <asp:ListItem Value="1">Chưa thi công</asp:ListItem>
                            <asp:ListItem Value="2">Đang thi công</asp:ListItem>
                            <asp:ListItem Value="3">Thi công Xong</asp:ListItem>
                        </asp:DropDownList>
                    </p>
                    <p>
                        <label>Nhận vật tư A:</label>
                        <asp:DropDownList ID="ddlNhanVatTuA" runat="server">
                            <asp:ListItem Value="1">Chưa nhận vật tư</asp:ListItem>
                            <asp:ListItem Value="2">Đã nhận vật tư</asp:ListItem>
                        </asp:DropDownList>
                    </p>
                    <p>
                        <label>Ghi chú:</label>
                        <asp:TextBox ID="txtNote" TextMode="MultiLine" runat="server" CssClass="textEntry description"></asp:TextBox>
                    </p>
                </div>
            </td>
        </tr>
    </table>
    <p>
        <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:GlobalStrings, Save %>"
            CssClass="submitButton" OnClick="btnSave_Click" />
        <input id="btnCancel" type="button" value="<%=GlobalStrings.Cancel %>"
            class="submitButton" onclick="CancelEdit();" />
    </p>

    <script type="text/javascript">
        var _khoiLuongId = <%=Request.Params["id"] %>;
        var _hopDongId = <%=Request.Params["hopDongId"] %>;
        var _src = '<%=Request.Params["src"] %>';
        $(function() {
            $(theForm).validationEngine();
            
            $("#<%=txtDiemDau.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/DiaDiem/Default.aspx/SearchDiaDiem",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
            
            $("#<%=txtDiemCuoi.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/DiaDiem/Default.aspx/SearchDiaDiem",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
            
            $("#<%=txtLoaiCap.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/LoaiCap/Default.aspx/SearchLoaiCap",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
        });

        function CancelEdit() {
            if (_src == 'TienDoThiCong') {
                window.location = 'TienDoThiCong.aspx';
            } else {
                window.location = 'KhoiLuong.aspx?hopDongId=' + _hopDongId + '#tabs-1';
            }
        }

        function split(val) {
            return val.split(/,\s*/);
        }

        function extractLast(term) {
            return split(term).pop();
        }
    </script>
</asp:Content>
